home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
038a
/
aplibs91.zip
/
APLIB-F.BAS
< prev
next >
Wrap
BASIC Source File
|
1991-05-17
|
9KB
|
233 lines
' ┌─────────────────────────────────────────────────────────────────┐
' │ A P L I B - F . B A S │
' │ │
' │ INCLUDE-FOOTER FILE TO ACCOMPANY HB's ALL-PURPOSE LIBRARY UNITS │
' └─────────────────────────────────────────────────────────────────┘
PRINT "ERROR!! Execution has reached the footer file APLIB-F.BAS !!"
BEEP: BEEP: BEEP: DELAY 3
END 1
Oops:
' ERROR HANDLING SUBROUTINE
' =======================
DO: LOOP UNTIL INKEY$ = "" ' first purge the keyboard buffer
SELECT CASE ERR
CASE 52, 53, 54, 55, 58, 61, 64, 67, 70, 71, 72, 73, 74, 75, 76
' if a dos error, it lets you know but goes on
PLAY "ML O0 C16 D64"
FileError = %True
L00 = CSRLIN: C00 = POS
CALL SCREENPUSH
IF ErrorMessage$ <> "" THEN
LOCATE 23,1: COLOR %Red, %Wht: CALL ClearLine
PRINT " => ";ErrorMessage$
END IF
BoxColor = %Wht + %Background * %Red
CALL QBox (%Center, 15, 1,_
"OOPS! DOS UNABLE TO FIND OR USE A FILE. ERROR" + STR$(ERR) +_
" @ " + STR$ (ERADR) , 0)
DELAY 1
CALL PressAKey
CALL SCREENPOP
LOCATE L00, C00
RESUME NEXT
CASE 24, 25, 27, 57
' if error is the printer, beeps til you press a key
DATA "P R I N T E R (or i/o) E R R O R"
DATA "====="
DATA "Please check the printer. Probably it is either"
DATA "off, not on-line, unplugged or out of paper."
DATA "Kindly FIX IT ... then PRESS SPACEBAR to go ahead"
DATA "with printing ... OR press [ESC] TO EXIT to DOS."
DATA END
L00 = CSRLIN: C00 = POS
CALL SCREENPUSH
IF ErrorMessage$ <> "" THEN
LOCATE 23,1: COLOR %Red, %Wht: CALL ClearLine
PRINT " => ";ErrorMessage$
END IF
RESTORE Oops
CALL BOXMESSAGE (%Center, %Center, 4)
DO
PLAY "O3 C64 P16 O4 C64 O3 P16 G-64"
FOR N = 1 TO 30
DELAY .1
IF INSTAT THEN EXIT FOR
NEXT
LOOP UNTIL INSTAT
CALL SCREENPOP
LOCATE L00, C00
IF INKEY$ = CHR$(27) THEN
CALL CloseFiles
LOCATE 23, 1
END 1
ELSEIF ErrorMessage$ = "fake error generated from HBDEMO menus" THEN
JustDemonstratingOops = %False
RESUME NEXT
ELSE
RESUME
END IF
CASE ELSE ' for all other errors we notify
PLAY "ML O0 C16 D64" ' user and quit ... UNLESS you set
IF ErrorMessage$ <> "" THEN ' it up to use ERFIND and
LOCATE 21,1: COLOR %Red, %Wht: CALL ClearLine ' QEdit to put you back in
PRINT " => ";ErrorMessage$ ' your code at the error !
END IF
LOCATE 22,1: COLOR %Red, %Wht: CALL ClearLine
PRINT " OOPS! UNABLE TO CONTINUE. ERROR";ERR;" AT ADDRESS ";ERADR;" "
COLOR %Red, %Gry
BXScreenSaved = %False
CALL CloseFiles
COLOR %Grn, %Blk
LOCATE 25,1: CALL ClearLine
LOCATE 24,1: CALL ClearLine
IF GoToSourceFile THEN ' this triggers the ERFIND sequence
IF LEN (RDisk$) < 2 THEN ' (see APLIB.DOC)
CALL SCREENPUSH
RESTORE DebugMsg
DebugMsg:
DATA "The GoToSourceFile flag was set in this program; but
DATA "to use the new AUTOMATIC DEBUGGING gimmick you also need"
DATA "to designate a drive letter as RDisk$ from your main"
DATA "program (D or E or whatever) to tell ApLib where to"
DATA "put temporary batch files. Normally this would be a
DATA "RAM-Disk. Also you need to have the shareware editor"
DATA "QEdit on your hard disk or somewhere DOS can use it."
DATA END
CALL BOXMESSAGE (0,0,0)
CALL PressAKey
CALL SCREENPOP
LOCATE 24,1
GoToSourceFile = %False
ELSE
IF NOT ColorDisplay THEN FlashBox = %True
CALL SCREENPUSH
CALL QBox (%Center, %Center, 1, "SEARCH FOR ERROR IN SOURCE FILE ? ", 8)
Yes = GETYESORNO
CALL SCREENPOP
IF Yes THEN
CLS
IF DIR$ (RDisk$ + "GETERR.&BA") <> "" THEN KILL RDisk$ + "GETERR.&BA"
IF DIR$ (RDisk$ + "GETERR.BAT") <> "" THEN
NAME RDisk$ + "GETERR.BAT" AS RDisk$ + "GETERR.&BA"
END IF
OutBat = FREEFILE
OPEN RDisk$ + "GETERR.BAT" FOR OUTPUT AS #OutBat ' create output bat file
A$ = "@echo off"
PRINT #OutBat, A$
IF ColorDisplay THEN
A$ = "Color 35"
PRINT #OutBat, A$
END IF
A$ = "cd " + SourceDir$
PRINT #OutBat, A$
A$ = "error " + STR$ (ERR)
PRINT #OutBat, A$
A$ = "pbc /ce /re" + LTRIM$ (STR$ (ERADR)) + " " + SourceFile$
PRINT #OutBat, A$
A$ = "ERFIND " + SourceFile$
PRINT #OutBat, A$
CLOSE #OutBat
CALL BufferStuffer (RDisk$ + "GETERR" + CHR$(13)) ' and run it
ELSE
LOCATE 24, 1
END IF
END IF
END IF
END 1 ' this places the DOS
END SELECT ' prompt at 25,1 for you
RESUME ' without messing up
' the display otherwise.
'
' ┌────────────────────────────────────┐
' │ E R R O R H A N D L E R │
' │ H A S E X I T E D T O D O S │
' │ Note: ERRORLEVEL is set to 1. │
' └────────────────────────────────────┘
SetBeeps:
LookitBeep$ = "MN T100 O5 C64 P64 O4 E64"
ArribaBeep$ = "MN T70 O2 A32 > E4"
'' ArribaBeep$ = "MN T70 O2 A32 P32 A32 A32 > E4"
TaskBeep$ = "MB T100 O3 C16 E32 F32 G16 E16 C16"
PressAKeyBeep$ = "T120 MS O4 G64 P16 G64 MN"
OopsBeep$ = "MN T120 O1 A64"
TinyBeep$ = "MS T240 O4 B-64"
' From HB PowerBasic Beep Tester, 02-26-91:
Tune6Beep$ = "O3 T180 MS E8 E4 E4 < B8 > C#4 < A4 P4 > A8"
RETURN
MZap:
NextScrn2Pop = MainMenuScreen ' handles clearing a pulldown
CALL SCREENPOP ' menu when Esc or right button
DEF SEG = VideoSeg&' is pressed ...
TopAtt = PEEK (1)
FOR I = 161 TO 320 STEP 2: POKE I, TopAtt: NEXT ' erases the cursor from the
DEF SEG ' TopBar menu (sets its color
RETURN ' the same as the rest)
ClickOrStrike:
DO: LOOP UNTIL INKEY$ <> "" OR MouseClicked
RETURN
SetColors:
IF COMMAND$ <> "" THEN
ScrColor = ReadParamFor ("ScrC") ' ReadParamFor looks
MenuColor = ReadParamFor ("MnuC") ' for a command line switch
BarColor = ReadParamFor ("BarC") ' like "BoxC=3F", for example,
WinColor = ReadParamFor ("WinC") ' which sets the color of a
FldColor = ReadParamFor ("FldC") ' box to &H3F (like COLOR 15,3)
BoxColor = ReadParamFor ("BoxC") ' that is, white letters on cyan
ELSE ' background ...
MenuColor = 0: BarColor = 0: WinColor = 0
FldColor = 0: BoxColor = 0: ScrColor = 0
END IF
' then if colors are not yet set (= 0) we give
' them a default value here:
IF ColorDisplay THEN
IF MenuColor = 0 THEN MenuColor = %ColorMenu
IF BarColor = 0 THEN BarColor = %ColorBar
IF WinColor = 0 THEN WinColor = %ColorWin
IF FldColor = 0 THEN FldColor = %ColorFld
IF BoxColor = 0 THEN BoxColor = %ColorBox
IF ScrColor = 0 THEN ScrColor = %ColorScr
ELSE
IF MenuColor = 0 THEN MenuColor = %MonoMenu
IF BarColor = 0 THEN BarColor = %MonoBar
IF WinColor = 0 THEN WinColor = %MonoWin
IF FldColor = 0 THEN FldColor = %MonoFld
IF BoxColor = 0 THEN BoxColor = %MonoBox
IF ScrColor = 0 THEN ScrColor = %MonoScr
END IF
RETURN
WipeLn:
ClP0 = POS
PRINT SPACE$(81-POS);
LOCATE CSRLIN, ClP0
RETURN
SUB Marker (Messg$) ' this is for debugging ...
LOCAL L,C
L = CSRLIN: C = POS
CALL SCREENPUSH
CALL QBox (%Center, %Center, 1, "Marker Message "+Messg$, 0)
DO: LOOP UNTIL INKEY$ <> ""
CALL SCREENPOP
LOCATE L,C
END SUB